<template>
	<view>
		<view class="center1 " style="flex-wrap: wrap;">
			<view class="bb1" @tap="" style="">
				<view class="mb-3  fs28 ls2">A区节点业绩</view>
				<view class="">{{acheve1}}</view>
			</view>
			<view class="bb1" @tap="">
				<view class="mb-3  fs28 ls2">A区总业绩</view>
				<span>{{achevement1}}</span>
			</view>
			<view class="bb1" @tap="">
				<view class="mb-3  fs28 ls2">B区节点业绩</view>
				<span>{{acheve2}}</span>
			</view>
			<view class="bb1" @tap="">
				<view class="mb-3  fs28 ls2">B区总业绩</view>
				<span>{{achevement2}}</span>
			</view>
		
		</view>
		
		<view class="center " v-for="(item,index) in sons" :key="index">
			<view class="d-flex bb" @tap="">
				<view class="flex-1 mt-3 mb-3 ml-2 fs28 ls2">
					<span>{{item.usernumber}}</span>
					<span>(个人：{{item.all}})</span>
				</view>
				<span style="color: red;">{{item.total}}</span>
			</view>
		</view>
	</view>
</template>
<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	export default {
		data() {
			return {
				acheve1: 0.00,
				acheve2: 0.00,
				achevement1: 0.00,
				achevement2: 0.00,
				
				sons:[],
			}
		},
		onLoad() {
			uni.showLoading({
				title: '加载中...'
			});

			if (this.hasLogin) {
				this.loadData();
			}

			setTimeout(() => {
				uni.hideLoading();
			}, 600)

		},
		onPullDownRefresh() {
			this.loadData('refresh')
		},

		//下拉到底获取新的数据
		onReachBottom() {
			if (!this.hasLogin) {
				this.islogin = true;
			} else {
				this.loadData()
			}
		},

		computed: {
			...mapState(['hasLogin']),
		},
		methods: {
			...mapMutations(['logout']),

			async loadData() {
				let token = uni.getStorageSync('token');

				if (!token) {
					this.$api.msg('token缺失！');
				}
				let url = '/getUserInfo';
				let res = await this.$myRequest({
					url: url,
					data: {
						token: token
					},
					methods: 'post'
				})

				let info = res.data.data;

				this.acheve1 = info['1_achieve'];
				this.acheve2 = info['2_achieve'];
				this.achevement1 = info['1_achievement'];
				this.achevement2 = info['2_achievement'];
				this.sons = info['sons'];
			},
		}
	}
</script>

<style>
	.btn {
		color: white;
		background-color: #29ad97;
		border-radius: 50rpx;
		margin: 100rpx 20rpx;
		font-size: 32upx;
		letter-spacing: 2upx;
	}

	page {
		background-color: #f0efee;
	}
	
	.center1 {
		width: 94%;
		height: 100%;
		/* background-color: white; */
		margin: 20rpx auto;
		border-radius: 20rpx;
		display: flex;
		justify-content: space-between;
	}
	
	.bb1 {
		border: 1rpx solid #f3f3f3;
		overflow: hidden;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		width: 40vw;
		height: 70px;
		background: #f8f9fc;
		position: relative;
		border-radius: 8px;
		background-position: 0 0;
		background-size: 69px 84px;
		background-repeat: no-repeat;
		margin-top: 20upx;
	}

	.center {
		width: 94%;
		height: 100%;
		background-color: white;
		margin: 20rpx auto;
		border-radius: 20rpx;
	}

	.bb {
		border: 1rpx solid #f3f3f3;
	}

	.d-flex {
		align-items: center;
	}

	.d-flex span {
		margin-right: 40upx;
	}
</style>
